<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
li{list-style: none;}
#tab {
    border-top: 1px solid rgb(231, 234, 236);
}
</style>
</head>
<body class="gray-bg">
<div class="container creditbody">
		 <div class="iboxtitle">
		 	<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷后业务>还款提醒</span>
         </div>
         <div class="buttonfixed">
		       <button type="button" class="btn dpbtn_blue" onclick="previous();"<c:if test="${empty previousBusiId }"> disabled="disabled"</c:if>>上一条</button>
			   <button type="button" class="btn dpbtn_red" onclick="next();"<c:if test="${empty nextBusiId }"> disabled="disabled"</c:if>>下一条</button>
	    </div>
         <div class="ibox-content ibox-con">
			<!-- 业务信息 -->
			<%@include file="/web/system/loanAfter/ywBusinessDetail_include.jsp"%>
			<div id="outer">
			    <ul id="tab">
			    	<c:if test="${hasBuyer }">
			        	<li class="current">购车人</li>
			        </c:if>
			        <c:if test="${hasGtBuyer }">
			       	 	<li>共同购车人</li>
			        </c:if>
			        <c:if test="${hasDbBuyer1 }">
			       	 	<li>担保人1</li>
			        </c:if>
			        <c:if test="${hasDbBuyer2 }">
			       	 	<li>担保人2</li>
			        </c:if>
			        <c:if test="${hasDbBuyer3 }">
			       	 	<li>担保人3</li>
			        </c:if>
			        <c:if test="${hasDbBuyer4 }">
			       	 	<li>担保人4</li>
			        </c:if>
			    </ul>
			    <div id="content">
		    		<c:if test="${hasBuyer }">
				        <ul class="ul-style xq-padding" style="display: block;">
				            <%@include file="/web/system/loanAfter/gcrxx.jsp"%>
				        </ul>
				    </c:if>
				    <c:if test="${hasGtBuyer }">
				        <ul class="ul-style xq-padding" <c:if test="${empty hasBuyer }">style="display: block;"</c:if>>
				          	<%@include file="/web/system/loanAfter/gtgcr.jsp"%>
				        </ul>
			        </c:if>
				    <c:if test="${hasDbBuyer1 }">
				        <ul class="ul-style xq-padding">
				          	<%@include file="/web/system/loanAfter/danbaoren1xx.jsp"%>
				        </ul>
			        </c:if>
				    <c:if test="${hasDbBuyer2 }">
				        <ul class="ul-style xq-padding">
				          	<%@include file="/web/system/loanAfter/danbaoren2xx.jsp"%>
				        </ul>
			        </c:if>
				    <c:if test="${hasDbBuyer3 }">
				        <ul class="ul-style xq-padding">
				          	<%@include file="/web/system/loanAfter/danbaoren3xx.jsp"%>
				        </ul>
			        </c:if>
				    <c:if test="${hasDbBuyer4 }">
				        <ul class="ul-style xq-padding">
				          	<%@include file="/web/system/loanAfter/danbaoren4xx.jsp"%>
				        </ul>
			        </c:if>
			    </div>
			</div>   
			<div class="business-manwife">车贷信息</div>	
			<div class="business-padding">
			   <table cellpadding="0" cellspacing="0" border="0" class="infor-table">
					<tr>
						<td align="right">
							<label class="control-label np">还款卡号：</label>
						</td>
						<td>
							<div class="control-div np">${dzLoanMiddleBank.cardnoRefund }</div>
						</td>
						<td align="right">
							<label class="control-label">签约贷款额：</label>
						</td>
						<td>
							<div class="control-div np"><fmt:formatNumber type="number" value="${ywBusinessLoan.signLoanAmount }" pattern="0.00" maxFractionDigits="2"/></div>
						</td>
						<td align="right">
							<label class="control-label">贷款期限：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessLoan.loanMonthDisplay }</div>
						</td>
					</tr>
					<tr>	
						<td align="right">
							<label class="control-label">签约月还款额(元)：</label>
						</td>
						<td>
							<div class="control-div np"><fmt:formatNumber type="number" value="${ywBusinessLoan.amountMonthly }" pattern="0.00" maxFractionDigits="2"/></div>
						</td>
						<c:if test="${ywBusinessLoan.loanBank =='BOC'}">
							<td align="right">
								<label class="control-label">签约首月还款额(元)：</label>
							</td>
							<td>
								<div class="control-div np"><fmt:formatNumber type="number" value="${ywBusinessLoan.firstMonthTotalAmount }" pattern="0.00" maxFractionDigits="2"/></div>
							</td>
						</c:if> 
					</tr>
				</table>
			</div>	 
			<div class="business-manwife">提醒方式</div>	
			<div class="business-padding">
			   <table cellpadding="0" cellspacing="0" border="0" class="infor-table">
						<tr>
							<td align="right">
								<label class="control-label np">手机号码1：</label>
							</td>
							<td>
								<div class="control-div np">${ywBusinessBuyer.tel1 }</div>
							</td>
							<td align="right"><label class="control-label">手机号码2：</label></td>
							<td>
								<div class="control-div np">${ywBusinessBuyer.tel2 }</div>
							</td>
							<td align="right"><label class="control-label">家庭电话：</label></td>
							<td>
								<div class="control-div np">${ywBusinessBuyer.familyTel }</div>
							</td>
							<td align="right"><label class="control-label">住址电话：</label></td>
							<td>
								<div class="control-div np">${ywBusinessBuyer.nowTel }</div>
							</td>
						</tr>
						<tr>	
							<td align="right"><label class="control-label">现住地址：</label></td>
							<td colspan="5">
								<div class="control-div np">${ywBusinessBuyer.nowAddr }</div>
							</td>
						</tr>
					</table>
			</div>	
			
			<div class="business-manwife">放款提醒登记</div>
			<div class="business-padding">
				<button type="button"  class="btn dpbtn_blue" onclick="addWarn();">新增提醒</button>
				<div class="padding-nono">
		          	<div class="jqGrid_wrapper">
			             <table id="table_list_1"></table>
			             <div id="pager_list_1"></div>
		         	</div>
	         	</div>
         	 </div>
			
			<form class="form-horizontal" id="commentForm">
				<div id="addtixing-layer" style="display: none;">
					<div class="business-padding">
						 <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
							<tr>	
								<td align="right">
									<label class="control-label np">通知时间：</label>
								</td>
								<td>
									<input  class="laydate-icon form-control" type="text" id="date_remind" name="date_remind" required="" placeholder="通知时间(必填)"   />
								</td>
							</tr>
							<tr>	
								<td align="right">
									<label class="control-label np">通知结果：</label>
								</td>
								<td  class="td-width">
									<mytag:selectTag id="result_remind_repayment" name="result_remind_repayment" map="${loanRemindResultType }" others="class='select-control' required='required'" />
								</td>
							</tr>
							<tr>	
								<td align="right" valign="top">
									<label class="control-label np">信息备注：</label>
								</td>
								<td>
									<textarea  class="form-control" id="remarks" name="remarks" cols="5" ></textarea>
								</td>
							</tr>
						</table>	
					</div>
				</form>
				<div class="padding-nono">
					<table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="100%">
						<tr>
							<td width="100%" align="center">
								 <div class="ibox-content">
						              <button type="button" class="btn dpbtn_green" onclick="warnSave();">确定</button>
						              <button type="button" class="btn dpbtn_red" onclick="cancel();">取消</button>
						          </div>
							</td>
						</tr>
					</table>
				</div>	
			</div>
	
	</div>
</div>	
	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
 	
 	<!-- layerDate plugin javascript -->
    <script type="text/javascript" src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    <!-- jqGrid -->
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>	
    <!--
    	作者：xiongxiaotun
    	时间：2017-07-25
    	描述：js
    -->
    <script type="text/javascript">
    
    function previous(){
	    window.location.href="${basePath}/DhRemindLoanViewController/dhRemindRefundDetail?id=${previousBusiId }";
	}
	
	function next(){
 	  	window.location.href="${basePath}/DhRemindLoanViewController/dhRemindRefundDetail?id=${nextBusiId }";
 	}
    
    function resetRemainForm(){
    	$('#date_remind').val();
    	$('#result_remind_repayment').val();
    	$('#remarks').val();
    }
    
	    jQuery(function($) { 
	    	changeJobStatus('zhujieren');
			changeJobStatus('peiou');
			
	    	getData();
	    	
	    	var $li = $('#tab>li');
	    	var $ul = $('#content .ul-style');
	        $li.click(function(){
	    		var $this = $(this);
	    		var $t = $this.index();
	    		$li.removeClass();
	    		$this.addClass('current');
	    		$ul.css('display','none');
	    		$ul.eq($t).css('display','block');
	    	});
	    	//外部js调用
		   laydate({
	            elem: '#date_remind',
	            format: 'YYYY-MM-DD',
	            min: '1970-01-01', //设定最小日期为当前日期
	            max: '2099-12-31', //最大日期
	            istime: false,
	            istoday: true
	        });
	    	
		   $("#commentForm").validate({
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
	    });
	    
	  //改变在职状态
    	function changeJobStatus(target){
    		var jobStatus = $('#' + target + "_jobStatus_code").val();
    		var affiliateStatus = $('#'+target+"_affiliateStatus_code").val();
    		if('01' == jobStatus) { //在职
    			$('.' + target +'_job_status_rel_remark').hide();
    	    	$('.' + target +'_job_status_rel').show();
    	    	
    			if(!affiliateStatus || affiliateStatus == '') {
    				affiliateStatus = '01';
    	 		}
    			if('01' == affiliateStatus) { //不挂靠
    		    	$('.' + target +'_affiliate_status_rel').hide();
    	 		} else if('02' == affiliateStatus){ //挂靠
    	 			$('.' + target +'_affiliate_status_rel').show();
    	 		}
    		} else if('02' == jobStatus){ //自由职业
    			$('.' + target +'_job_status_rel').hide();
    	    	$('.' + target +'_job_status_rel_remark').show();
    	    	
    			$('.' + target +'_affiliate_status_rel').hide();
    		}
    	}
	  
	  
	    var addtixinglayer;	
	    
	    function addWarn(){
	    	addtixinglayer=layer.open({
		    	  type: 1,
		    	  title: '新增提醒',
		    	  shadeClose: true,
		    	  shade: 0.1,
		    	  area: ['350px', '350px'],
		    	  content: $("#addtixing-layer"),
	    	});
	    }
	    
	    function cancel(){
	    	layer.close(addtixinglayer);
	    	$("#date_remind").val("");
			$("#result_remind_repayment").val("");
			$("#remarks").val("");
	    }
	    
	    
	    var getData = function()
	    {
	  var winWidth = $('div.ibox-content').width();
	        var winHeight = document.body.offsetHeight - 300;
	     	var win = winWidth / 5 - 20;
  	 	   $.jgrid.defaults.styleUI = 'Bootstrap';
		  jQuery("#table_list_1").jqGrid
		  ({
			url:'${basePath}/DhRemindLoanSubController/list?remindLoanType=2&busiId='+'${busiId}',
	        datatype : "json",
	        colNames : [ '主键', '提醒类型','提醒通知时间', '还款提醒通知结果','经办人',  '备注'],
	        colModel : [ 
	                     {name: 'replaceId', index: 'id', hidden:true},
	                     {name: 'remindLoanTypeDisplay',index: 'remindLoanType',width: win,align: "center"},
	                  	 {name: 'dateRemind',index: 'dateRemind',width: win,align: "center",formatter:function(a){
	                  		 return (a && a != '') ? formateToDate(a) : '';
	                  	 }},
	               		 {name: 'resultRemindRepaymentDisplay',index: 'resultRemindRepayment',width: win,align: "center"},
	               		 {name: 'creatorName',index: 'creatorName',width: win,align: "center"},
	            		 {name: 'remarks',width: win,align: "center",sortable:false}
	                   ],
              mtype : "post",
              height: 200,
              width:winWidth,  
              autowidth: false,
              shrinkToFit: false,
              rowNum: 15,
              rowList: [15, 30, 45],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : false,
              altRows:true,
	           altclass:'someClass',
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
	      });
	    }	   
	    
	    
	    var refresh = function() {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
	    
	    var warnSave = function() {
	    	var busiId = '${busiId}';
	    	var remind_loan_type = 2;
	    	var date_remind = $('#date_remind').val();
	    	var result_remind_repayment = $('#result_remind_repayment').val();
	    	var remarks = $('#remarks').val();
	    	var validstatus = $("#commentForm").valid();
   	    	if(validstatus)
   	    	{
		    	//询问框
		 		layer.confirm('确认执行本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
		 		  btn: ['确定','取消'] //按钮
		 		}, function(){
		 			  layer.closeAll();
		 			 resetRemainForm();
		 			  $.dpAjax({
			 			url:'${basePath}/DaiHouYwController/diepuFangKuanHuanKuan',
			 			data:{
			 				"busiId":busiId,
			 				"remindLoanType":remind_loan_type,
			 				"dateRemind":date_remind,
			 				"resultRemindRepayment":result_remind_repayment,
			 				"remarks":remarks
			 			},
			 			success: function(datas) {
			 				layer.close(addtixinglayer);
			 				$("#date_remind").val("");
			 				$("#result_remind_repayment").val("");
			 				$("#remarks").val("");
			 				layer.msg("执行成功！", {icon: 6});
			 				refresh();
			 		     }
			 		});
		 		}, function(){
		 			layer.msg('已取消本次操作！', {icon: 6});
		 		});
   	    	}
	    }
    </script>
</body>
</html>
